package zdream.pmfield.test.data.foe;

import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

import zdream.pmfield.data.foe.Foe;
import zdream.pmfield.data.foe.FoeTemplate;
import zdream.pmfield.data.foe.VStat;
import zdream.pmfield.storage.FoeTemplateStorage;

import static org.junit.Assert.*;

/**
 * @author Zdream
 * @date 2023-11-10
 * @since 0.0.1
 */
public class FoeCase {
	FoeTemplateStorage storage;

	@Before
	public void before() {
		storage = new FoeTemplateStorage();
		storage.loadFoes();
	}

	@Test
	public void testFoeVStat() {
		Foe foe = Foe.builder(storage.findFoeById(1))
				.withLevel(10)
				.build();
		int sum = 0;
		for (int i = 0; i < foe.vStats.length; i++) {
			sum += foe.vStats[i];
		}
		assertEquals(sum, FoeTemplate.V_STAT_BASIC_VALUE * foe.vStats.length);
		assertEquals(foe.vStats[VStat.LUCK.ordinal()], FoeTemplate.V_STAT_BASIC_VALUE);
	}

	@Test
	public void createMoreFoe() {
		for (int foeId = 1; foeId <= 151; foeId++) {
			final FoeTemplate template = storage.findFoeById(foeId);
			if (template == null) {
				continue;
			}

			for (int level = 5; level <= 100; level += 5) {
				Foe foe = Foe.builder(template)
						.withLevel(level)
						.skipShuffleVStat()
						.build();
				System.out.println("raw: " + foe);

				Arrays.fill(foe.vStats, (short) 95);
				foe.updater().build();
				System.out.println("max: " + foe);
			}
		}
	}
}
